extends ColorRect

export var right_action = "ui_right"
export var left_action = "ui_left"

onready var SPEED = get_viewport().size.x

func _process(delta):
	if Input.is_action_pressed(right_action):
		move(delta, 1)
	if Input.is_action_pressed(left_action):
		move(delta,-1)


func move(delta, direction):
	var newpos = rect_position+Vector2(SPEED*delta*sign(direction), 0)
	if newpos.x > 0 and newpos.x < get_viewport().size.x-rect_size.x:
		rect_position = newpos

func ping():
	$PING.play()
